Documentation for Users  2.1.2
Perception Toolbox for Virtual Reality (PTVR) Manual
reticle_(3_ways_of_creating_a...).py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 """
3 ...\PTVR_Researchers\Python_Scripts\Demos\Pointing\
4  reticle_(3_ways_of_creating_a...).py
5 
6 Goal: show three ways of creating a reticle corresponding to three different goals.
7  The 3 reticles are simultaneously displayed close together with
8  different perimetric coordinates.
9  They are Head-contingent in this demo.
10 
11 Note 1 : The reticle belongs to the PTVR category called "flat cursors".
12 
13 Note 2:
14  when using ImageFromLoading (),
15  the default is to use a file that is stored in:
16  ...\PTVR_Researchers\PTVR_Operators\resources\Images\
17  However, you can use the 'path_to_image_folder' parameter to get files
18  that are stored in paths outside of ...\PTVR_Researchers.
19 
20 """
21 
22 from PTVR.Visual import The3DWorld
23 from PTVR.Stimuli.Scenes import VisualScene
24 from PTVR.Stimuli.Objects import Sphere, Cube
25 import PTVR.Stimuli.Color as color
26 import numpy as np
27 from PTVR.Pointing.PointingCursor import *
31 
32 from PTVR.SystemUtils import LaunchThe3DWorld
33 import PTVR.Tools as tools
34 
35 # =============================================================================
36 # PARAMETERS #
37 # =============================================================================
38 my_contingency = ImageContingency.HEADSET
39 
40 # =============================================================================
41 # END PARAMETERS #
42 # =============================================================================
43 
44 # the simplest experiment
45 my_world = The3DWorld ()
46 def main():
47  my_world.translate_coordinate_system_along_global ( np.array([0, 1.2, 0]))
48  my_scene = VisualScene ()
49 
50 
52  my_reticle_image = RG.ReticleImageFromDrawing ()
53  # If you want to open a window on your PC showing the reticle image
54  # that has just been created, comment out the following line.
55  #my_reticle_image.Show()
56  my_reticle_cursor = ImageToContingentCursor (
57  image = my_reticle_image,
58  contingency_type = my_contingency)
59  # you could also do the same as the 2 lines above with the following line:
60  # my_reticle_cursor = ImageToContingentCursor( image = RG.ReticleImageFromDrawing () )
61  my_scene.place_contingent_cursor (my_reticle_cursor)
62 
63 
67  my_reticle_image_2 = SFD.ImageFromDrawing (
68  color = color.RGBColor ( g = 0.7),
69  shape = "rectangle", line_width_as_ratio = 0.05 )
70  my_reticle_cursor_2 = ImageToContingentCursor (
71  image = my_reticle_image_2,
72  contingent_cursor_ecc_hm =
73  np.array ( [ 5, 90 ]), # 5° above
74  contingency_type=my_contingency )
75  my_scene.place_contingent_cursor (my_reticle_cursor_2)
76 
77 
81  my_reticle_image_3 = SFL.ImageFromLoading (
82  #path_to_image_folder = r"C:\Users\Eric_Castet",
83  # you can uncomment the line above to enter the path on
84  # your PC to your own image files.
85  image_file = "mouse_cursor_blue_arrow.png" )
86  my_reticle_cursor_3 = ImageToContingentCursor (
87  image = my_reticle_image_3,
88  contingent_cursor_ecc_hm =
89  np.array ( [ 5, 270 ]), # 5° below,
90  contingency_type = my_contingency )
91  my_scene.place_contingent_cursor (my_reticle_cursor_3)
92 
93  my_world.add_scene (my_scene)
94  my_world.write ()
95 
96 if __name__ == "__main__":
97  main()
98  LaunchThe3DWorld() # Launch the Experiment with PTVR.
def LaunchThe3DWorld(jsonFileCategory="Externals")
Definition: SystemUtils.py:182